def is_prime(n):    
    if n <= 1:    
        return False    
    for i in range(2, int(n ** 0.5) + 1):    
        if n % i == 0:    
            return False    
    return True    
    
def palindromic(num):    
    return str(num) == str(num)[::-1]    
    
def reverse_num(num):    
    return int(str(num)[::-1])    
    
def reverse_primes_between(start, end):    
    for i in range(start, end + 1):    
        if not palindromic(i) and is_prime(i) and is_prime(reverse_num(i)):    
            print(i)    
    
start = int(input())  
if start <= 1:  
    raise ValueError()  
  
end = int(input())  
if end <= 1 or end < start:  
    raise ValueError()  
  
reverse_primes_between(start, end)